Skip to content

Conversation

@davidparsson
Copy link
Collaborator

To allow passing type checking without having to explicitly declare types.

@codecov
Copy link

codecov bot commented Jan 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.54%. Comparing base (602caec) to head (1589f3f).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #307   +/-   ##
=======================================
  Coverage   96.54%   96.54%           
=======================================
  Files           1        1           
  Lines         608      608           
  Branches      103      103           
=======================================
  Hits          587      587           
  Misses         15       15           
  Partials        6        6           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

To avoid the need for explicit typing when using the method.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the multibind method to accept covariant collection types (Collection and Mapping) instead of concrete types (list and dict). This change allows callers to pass subtypes like tuples or immutable mappings without explicit type declarations, improving type checking compatibility.

Key changes:

  • Runtime type checks updated from list to Collection and dict to Mapping
  • Type signatures updated to accept Collection[Union[T, Type[T]]] and Mapping[K, Union[V, Type[V]]] instead of concrete List and Dict types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

except IndexError:
raise InvalidInterface(f"Use typing.List[T] or list[T] to specify the element type of the list")
if isinstance(to, list):
if isinstance(to, Collection):
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using isinstance(to, Collection) will incorrectly match strings since strings are collections in Python. This could cause the code to iterate over individual characters instead of treating the string as an invalid input. Add an explicit check to exclude strings: if isinstance(to, Collection) and not isinstance(to, (str, bytes)):

Suggested change
if isinstance(to, Collection):
if isinstance(to, Collection) and not isinstance(to, (str, bytes)):

Copilot uses AI. Check for mistakes.
@davidparsson davidparsson merged commit f6277d1 into master Jan 9, 2026
14 checks passed
@davidparsson davidparsson deleted the covariant-type branch January 9, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants